<?php
/**
 * Created by PhpStorm.
 * User: Thans
 * Date: 2018/1/3
 * Time: 下午3:20
 */
namespace app\common\exception;

use Exception;
use think\exception\Handle;
use think\exception\ValidateException;

class Http extends Handle
{
    public function render(Exception $e)
    {
        // 参数验证错误
        if ($e instanceof ValidateException) {
            $msg = $e->getError();
        } else {
            $msg = $e->getMessage();
        }
        // 其他错误交给系统处理
        return json([
            'code' => '404',
            'msg'=>$msg,
            'data'=>$e,
        ], 404);
    }
}
